<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex learningTasks_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between learningTasks_fd0_0'>
					<view class='flex flex-wrap align-center learningTasks_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  learningTasks_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-center'>
						<text class='learningTasks_fd0_0_c1_c0'>学习任务</text>
					</view>
					<view class='flex align-center justify-end learningTasks_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="navigateTo" :data-url="`/pages/my/addTask/addTask`">
						<text class='learningTasks_fd0_0_c2_c0'>添加学习任务</text>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex benben-flex-layout flex-wrap align-center">
				<view>
					<benben-flex-tabs class-name='learningTasks_benbenTabsfd1_0' v-model="tabs" ref="benben_tabsfd1_0"
						select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false'
						:open-sticky='true' :top='0' :is-show-content='false' :scrollspy='false'
						:tabs-info.sync="tabsInfofd1_0" @change="getStudyFunc()">

						<scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
							class="benben-tabs" style="width:750rpx" :scroll-x="true"
							:scroll-left.sync="tabsInfofd1_0.moveX" scroll-with-animation="all .3s ease">
							<view class="benben-tabs-content" id="benben_tabsfd1_0-content">
								<view id="benben_tabsfd1_0-title"
									class="benben-tabs-title flex flex align-center justify-around">
									<view
										:class="{ 'checkTitlefd1_0': tabs == '0', 'flex flex-wrap align-center': true }"
										@tap="tabs = '0'" :id="`benben_tabsfd1_0-title-item-${'0'}`">

										<text>全部</text>

									</view>
									<view
										:class="{ 'checkTitlefd1_0': tabs == '1', 'flex flex-wrap align-center': true }"
										@tap="tabs = '1'" :id="`benben_tabsfd1_0-title-item-${'1'}`">

										<text>未发布</text>

									</view>
									<view
										:class="{ 'checkTitlefd1_0': tabs == '2', 'flex flex-wrap align-center': true }"
										@tap="tabs = '2'" :id="`benben_tabsfd1_0-title-item-${'2'}`">

										<text>已发布</text>

									</view>
								</view>
								<view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
									id="benben_tabsfd1_0-line"
									class="benben-tabs-line flex benben-flex-tabs-line learningTasks_linefd1_0"></view>
							</view>
						</scroll-view>

					</benben-flex-tabs>

				</view>
			</view>

			<!---flex布局flex布局结束-->
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout learningTasks_flex_2">
				<template v-for='(item,key0) in studyList'>
					<view class='flex flex-direction flex-wrap align-stretch learningTasks_fd2_0' :key='key0'>
						<view class='flex flex-wrap align-center learningTasks_fd2_0_c0'>
							<view
								class='flex flex-direction flex-wrap align-stretch flex-sub learningTasks_fd2_0_c0_c0'>
								<view class='flex flex-wrap align-center learningTasks_fd2_0_c0_c0_c0'>
									<text class='learningTasks_fd2_0_c0_c0_c0_c0'>任务名称：</text>
									<text class='flex-sub learningTasks_fd2_0_c0_c0_c0_c1'>{{item.task}}</text>
								</view>
								<view class='flex flex-wrap align-center learningTasks_fd2_0_c0_c0_c0'>
									<text class='learningTasks_fd2_0_c0_c0_c1_c0'>课程名称：</text>
									<text
										class='flex-sub learningTasks_fd2_0_c0_c0_c1_c1'>{{item.kechengmingcheng}}</text>
								</view>
								<view class='flex flex-wrap align-center'>
									<text class='learningTasks_fd2_0_c0_c0_c1_c0'>截止时间：</text>
									<text class='learningTasks_fd2_0_c0_c0_c1_c0'>{{item.end_time}}</text>
								</view>
							</view>
							<benben-switch v-model="item.status" default-color='#dcdfe6' color='#E31D1A'
								:disabled='false' :auto='true' size='65'
								@change="postReleaseFunc(item.status,item.aid)">
							</benben-switch>
						</view>
						<view class='flex flex-wrap align-center justify-end learningTasks_fd2_0_c1'>
							<button class='learningTasks_fd2_0_c1_c0' @tap.stop="postDeleteFunc(item.aid)">删除</button>
							<button class='learningTasks_fd2_0_c1_c1' @tap.stop="handleJumpDiy" data-type="navigateTo"
								:data-url="`/pages/my/addTask/addTask?id=${item.aid}&shopID=${shopID}`">编辑</button>
						</view>
					</view>
				</template>
				<fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
					:listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import pagingList from '@/common/mixin/paging_list.js';
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},
		mixins: [pagingList],

		data() {
			return {
				"tabsInfofd1_0": {
					lineleft: '',
					lineWidth: '',
					moveX: 0,
					scrollX: 0,
					PageScrollX: 0
				},
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"tabs": "0",
				"shopID": uni.getStorageSync('shopID') || '',
				"studyList": []
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.shopID = uni.getStorageSync('shopID') || ''
			this.getStudyFunc()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			this.getStudyFunc()
		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取学习任务列表
			getStudyFunc() {
				this.minixPagingListsApi = global.apiUrls.post6524f8e9d865d;
				this.pageingListApiMethod = 'get';
				this.allowOnloadGetList = false;
				this.pagingListPostDataContent = {
					shopID: this.shopID,
					status: this.tabs
				}
				this.listData = [];
				this.studyList = this.listData;
				this.pagingListToggle();

			},
			//提交是否发布
			async postReleaseFunc(statusID, studyID) {
				//请求方法
				//数据验证

				let data6524f91806142 = await this.$api.post(global.apiUrls.post6524f91806142, {
					status: statusID,
					aid: studyID
				});

				if (data6524f91806142.data.code != 1) {
					this.$message.info(data6524f91806142.data.msg);
					return
				}



			},
			//提交删除学习任务
			async postDeleteFunc(deleteID) {
				//请求方法
				//数据验证

				let data652528deb3c5f = await this.$api.dbGet(global.apiUrls.post652528deb3c5f, {
					aid: deleteID
				});
				if (!data652528deb3c5f) return
				if (data652528deb3c5f.data.code != 1) {
					this.$message.info(data652528deb3c5f.data.msg);
					return
				}



				this.$message.info('删除成功');
				this.getStudyFunc()
			},
			pagingListPostData() {
				return this.pagingListPostDataContent
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.learningTasks_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.learningTasks_fd0_0_c2_c0 {
		font-size: 26rpx;
		font-weight: 500;
		color: #333333;
	}

	.learningTasks_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
	}

	.learningTasks_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.learningTasks_fd0_0_c0 {
		width: 180rpx;
		height: 88rpx;
	}

	.learningTasks_fd0_0 {
		border-bottom: 1px solid #eee;
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.learningTasks_linefd1_0 {
		background: #E31D1A;
		width: 40rpx;
		height: 8rpx;
		top: 80rpx;
		background-size: 100% auto !important;
		border-radius: 16rpx;
	}

	.checkTitlefd1_0 {
		font-weight: 700 !important;
		font-size: 28rpx !important;
		color: #E31D1A !important;
		background-color: rgba(255, 255, 255, 1) !important;
	}

	::v-deep .learningTasks_benbenTabsfd1_0 {
		background: #fff;
		width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		text-align: center;
	}

	.learningTasks_flex_2 {
		padding: 20rpx 32rpx 20rpx 32rpx;
	}

	.learningTasks_fd2_0_c1_c1 {
		background: #E31D1A;
		border-radius: 33rpx 33rpx 33rpx 33rpx;
		width: 100rpx;
		line-height: 50rpx;
		font-size: 24rpx;
		color: #fff;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.learningTasks_fd2_0_c1_c0 {
		background: #E31D1A;
		border-radius: 33rpx 33rpx 33rpx 33rpx;
		width: 100rpx;
		line-height: 50rpx;
		font-size: 24rpx;
		color: #fff;
	}

	.learningTasks_fd2_0_c1 {
		border-top: 1px solid #eee;
		padding: 24rpx 0rpx 24rpx 0rpx;
	}

	.learningTasks_fd2_0_c0_c0_c1_c1 {
		font-size: 24rpx;
		font-weight: 500;
		color: #333;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-height: 33rpx;
		max-width: 200rpx;
	}

	.learningTasks_fd2_0_c0_c0_c1_c0 {
		font-size: 24rpx;
		font-weight: 500;
		color: #333;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-height: 33rpx;
	}

	.learningTasks_fd2_0_c0_c0_c0_c1 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.learningTasks_fd2_0_c0_c0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-height: 40rpx;
	}

	.learningTasks_fd2_0_c0_c0_c0 {
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.learningTasks_fd2_0_c0_c0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.learningTasks_fd2_0_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.learningTasks_fd2_0 {
		background: #fff;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 24rpx 32rpx 0rpx 32rpx;
		margin: 0rpx 0rpx 20rpx 0rpx;
	}
</style>